<!DOCTYPE html>
  <html lang="en">
  <head>
      <meta charset="UTF-8">
      <title>js鼠标经过切换图片</title>
      <script>
          window.onload = function () {
              //获取图片
              var img = document.getElementById("img");
 
             //鼠标经过图片
             img.onmouseover = function () {
                 this.src = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1587136371052&di=d4df3ad539ad0d5236b68cdafcd83420&imgtype=0&src=http%3A%2F%2Fimg0.pconline.com.cn%2Fpconline%2F2004%2F16%2F13362593_12_thumb.jpg"
             }
 
             //鼠标离开图片
             img.onmouseout = function () {
                 this.src = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1591712133126&di=78db7711d274daaea3a3c781843b2c39&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn%2Fw620h826%2F20180307%2Fdcd5-fxipenp2952637.jpg"
             }
         }
     </script>
 </head>
 <body>
     <img id="img" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1591712133126&di=78db7711d274daaea3a3c781843b2c39&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn%2Fw620h826%2F20180307%2Fdcd5-fxipenp2952637.jpg"/>
 </body>
 </html>